f = open("D:/word.txt", "r", encoding="UTF-8")
# 方式1：读取全部内容，通过字符串count方法统计itheima单词数量
# count = f.read().count("itheima")
# print(f"itheima出现的次数是：{count}")
# 方式2：读取内容，一行一行读取
count = 0
i = 0
for line in f:
    line = line.strip()
    words = line.split(" ")
    for word in words:
        if word == "itheima":
            count += 1
print(f"itheima出现的次数是：{count}")
f.close()
